﻿using System;
using System.Collections.Generic;

using Newtonsoft.Json.Linq;
using xbmc_json_async.Utilities;
using xbmc_json_async.System;

namespace xbmc_json_async.Media
{
    
    public class Season : xbmc_json_async.Types.Video.Details.Season
    {
        
        public Season(int id, string label, string thumbnail, string genre, int year, float rating)
        {
            throw new NotImplementedException("Use empty constructor and populate from Json");
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="Season"/> class.
        /// </summary>
        public Season()
        {
            
        }

        /// <summary>
        /// Froms the json object.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        public static Season FromJsonObject(JObject item)
        {
            var season = new Season();
            season.episode = XHelpers.Jval(item, "episode");
            season.fanart = XHelpers.Jval(item, "fanart");
            season.label = XHelpers.Jval(item, "label");
            season.playcount = XHelpers.JvalInt(item, "playcount");
            season.showtitle = XHelpers.Jval(item, "showtitle");
            season.thumbnail = XHelpers.Jval(item, "thumbnail");
            season.tvshowid = XHelpers.JvalInt(item, "tvshowid");

            /*Injector injector = new Injector();
            var vObj = (object)season;
            season = (Season)injector.FillObject(vObj, (object)item);
            */
            return season;

            
        }

        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            return label;
        }
    }
}
